package com.apes.fn.server.praticalFunction.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.product.model.Classify;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * Created by lishikun on 2021/6/11 10:44
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = AdapterClassify.CONST_TABLE_NAME)
public class AdapterClassify extends BaseModel {
    public static final String CONST_TABLE_NAME = "adapter_category";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "适用品类",prefix="1",padding = 6)
    @Comment("编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "category_id", referencedColumnName = "id")
    @Comment("品类")
    private Classify classify;

    @Comment("组别")
    @Column(name = "grade")
    private int grade = 0;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "smart_accessories_config_id", referencedColumnName = "id")
    @Comment("赋能客户车辆扩展信息")
    private SmartAccessoriesConfig smartAccessoriesConfig;
}
